在一個 分散式版本控制系統,並不存在單一的中央倉庫要求所有人依賴。相反地,協作是一種社會慣例,而非技術上的必要條件。本課將介紹 補丁工作流程,這正是像 Linux 核心等高完整性專案的黃金標準。
1. 定義補丁
一個 補丁 是將單個提交發送給另一位開發者的方式。它是一種純文字檔案,通常用於分享提交,而無需共享整個分支或提供對伺服器的寫入權限。
2. 補丁工作流程圖
在此模型中,開發者各自獨立工作,並將其貢獻提交給專案維護者(整合者)。
3. 整合者模型
專案的完整性由指定的負責人透過篩選貢獻來維持。開發者產生補丁,並透過 電子郵件傳送。整合者會在私密環境中審核這些補丁,再執行 推送 至 官方倉儲,以確保每一行代碼都經過審查。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
QUESTION 1
In a distributed version control system, why is the 'official repository' considered a social convention?
Because Git technically forces every user to use a central server.
Because every contributor holds a full-fidelity history, making any repo potentially 'central'.
Because it is the only place where the .git folder exists.
Because patches cannot be applied to local repositories.
✅ Correct!
Exactly. Git is peer-to-peer; the 'official' status is simply an agreement among the developers.❌ Incorrect
Git does not force a central server. Every developer's local copy is a complete repository.QUESTION 2
Which of the following best defines a 'patch' in Git?
A full backup of the entire project database.
A way to share specific commits without needing shared access to a branch.
A command that deletes experimental code.
An encrypted key used for SSH authentication.
✅ Correct!
Correct! Patches serialize a commit into a text file that can be sent via email.❌ Incorrect
Patches are focused on individual changes (commits), not the whole project or security keys.QUESTION 3
What is the primary role of the 'Integrator' in the patch workflow?
To write the majority of the project's source code.
To act as a gatekeeper, reviewing and applying patches to the official repository.
To host the mailing list server.
To automatically merge all incoming emails into the master branch.
✅ Correct!
The integrator ensures code quality by reviewing patches before they reach the main history.❌ Incorrect
The integrator is a human gatekeeper, not an automated script or a server host.QUESTION 4
Which command is typically used to create these portable commit files?
git push --patchgit format-patchgit send-commitgit commit --export✅ Correct!
git format-patch is the standard command for generating email-ready patch files.❌ Incorrect
git format-patch is the correct tool for this specific serialization.QUESTION 5
In the diagram provided, what is the action taken by the Developer toward the Official Repository?
Push
Pull
Format
Review
✅ Correct!
Developers 'Pull' from the official repo to stay updated; they do NOT 'Push' directly to it in this workflow.❌ Incorrect
In a patch workflow, developers do not have push access; they pull changes to stay in sync.Case Study: The Linux Kernel Model
Decentralized Collaboration Governance
You are the maintainer of a popular open-source library. To prevent low-quality code from entering the master branch, you decide to move away from a 'Shared Central Repo' model to an 'Integrator' model.
Q
Why would an email-based patch workflow be superior for a project with thousands of global contributors who don't know each other?
Solution:
It allows for rigorous asynchronous review. Contributors don't need 'write access' (which is a security risk), and every change is forced through a gatekeeper (the maintainer) who can audit the logic before it becomes part of the permanent history.
It allows for rigorous asynchronous review. Contributors don't need 'write access' (which is a security risk), and every change is forced through a gatekeeper (the maintainer) who can audit the logic before it becomes part of the permanent history.
Q
What is the difference between a developer's local repository and the 'official' repository in this scenario?
Solution:
Technically, they are identical distributed repositories. Socially, the 'official' repository is simply the one the community agrees to treat as the source of truth, usually managed by the lead integrator.
Technically, they are identical distributed repositories. Socially, the 'official' repository is simply the one the community agrees to treat as the source of truth, usually managed by the lead integrator.